<template>
	<u-popup :show="modelValue" @close="$emit('update:modelValue',false)">
		<view style="background-color: #eee;">
			<view style="background-color: white;margin-bottom: 5px;box-shadow: 0 0 4px 0 #77777744;">
				<view  @click="onViewDetails"
					class="bottom_line" style="text-align: center;margin: 0px;padding: 20px 15px;display: flex;justify-content: space-between;align-items: center;">
					<view style="flex:1 0 0;font-size: 14px;display:flex;justify-content: center;">
						<u-icon name="eye" color="#87ee00"></u-icon>
						<span style="padding-left:5px">详情预览</span>
					</view>
				</view>
			</view>
			
			<view style="background-color: white;margin-bottom: 5px;box-shadow: 0 0 4px 0 #77777744;">
				<view  @click="onAddJob"
					class="bottom_line" style="text-align: center;margin: 0px;padding: 20px 15px;display: flex;justify-content: space-between;align-items: center;">
					<view style="flex:1 0 0;font-size: 14px;display:flex;justify-content: center;">
						<u-icon name="plus" color="#ee00c3"></u-icon>
						<span style="padding-left:5px">添加岗位</span>
					</view>
				</view>
				
				<view  @click="onJobModify"
					class="bottom_line" style="text-align: center;margin: 0px;padding: 20px 15px;display: flex;justify-content: space-between;align-items: center;">
					<view style="flex:1 0 0;font-size: 14px;display:flex;justify-content: center;">
						<u-icon name="edit-pen" color="#ee9f00"></u-icon>
						<span style="padding-left:5px">活动编辑</span>
					</view>
				</view>
			</view>
			
			<view style="background-color: white;margin-bottom: 5px;box-shadow: 0 0 4px 0 #77777744;">
				<view  @click="onOrganize"
					class="bottom_line" style="text-align: center;margin: 0px;padding: 20px 15px;display: flex;justify-content: space-between;align-items: center;">
					<view style="flex:1 0 0;font-size: 14px;display:flex;justify-content: center;">
						<u-icon name="calendar" color="#008dce"></u-icon>
						<span style="padding-left:5px">组织管理</span>
					</view>
				</view>
				<view  @click="onComplete"
					class="bottom_line" style="text-align: center;margin: 0px;padding: 20px 15px;display: flex;justify-content: space-between;align-items: center;">
					<view style="flex:1 0 0;font-size: 14px;display:flex;justify-content: center;">
						<u-icon name="checkmark-circle-fill" color="#80cc4a"></u-icon>
						<span style="padding-left:5px">完结活动</span>
					</view>
				</view>
				<view  @click="onTaskCancel"
					class="bottom_line" style="text-align: center;margin: 0px;padding: 20px 15px;display: flex;justify-content: space-between;align-items: center;">
					<view style="flex:1 0 0;font-size: 14px;display:flex;justify-content: center;">
						<u-icon name="error-circle" color="#ff4507"></u-icon>
						<span style="padding-left:5px">取消活动</span>
					</view>
				</view>
			</view>
			
			<view style="background-color:white;color:red">
				<view  @click="onCancel"
					class="bottom_line" style="text-align: center;margin: 0px;padding: 20px 15px;display: flex;justify-content: space-between;align-items: center;">
					<view style="flex:1 0 0;font-size: 14px;">取消</view>
				</view>
			</view>
		</view>
	</u-popup>
</template>

<script>
	export default {
		props:{
			modelValue:{
				type:Boolean,
				default:false
			},
			currentTask:{
				type:Object,
				default:null
			}
		},
		inject:['_scope'],
		data(){
			return {
				
			}
		},
		methods:{
			onViewDetails(){
				this.$emit('update:modelValue',false)
				
				// // this.modelValue = false
				// // this.pageParam.task_details =  this.currentTask
				// // this.pageParam.details_preview = true
				// // console.log(this.currentTask)
				uni.navigateTo({
					url:`/pages/job/user/job-details/job-details?id=${this.currentTask.id}&preview=true`
				})
				
				console.log(this.currentTask)
			},
			onAddTask(){
				this.pageParam.task = null
				
				uni.navigateTo({
					url:"/pages/job/publish/publish-form"
				})
			},
			onAddJob(){
				//this.modelValue = false
				this.$emit('update:modelValue',false)
				this.showAddJobPopup = true
			},
			onJobModify(){
				//this.modelValue = false
				this.$emit('update:modelValue',false)
				//this.pageParam.task = this.currentTask
				uni.navigateTo({
					url:`/pages/job/publish/publish-form?id=${this.currentTask.id}`
				})
			},
			onOrganize()
			{
				//this.modelValue = false
				this.$emit('update:modelValue',false)
				console.log(this.currentTask)
				this.pageParam.project_organize = this.currentTask
				
				uni.navigateTo({
					url:'/pages/job/publish/job-organize/job-organize'
				})
			},
			async onComplete()
			{
				//await this.operate('complete')
				console.log(this._scope) 
				
				let res = await this.$http.post('/manager/job/task/operate',{
					task_ids:[this._scope.task.id],
					type:'completed',
					//op:'cancel'
				})
				
				console.log(res.data)
				
				this._scope.task = Object.assign(this._scope.task,res.data)
				console.log(this._scope.task)
				
				uni.$emit('job-actions-done')
			},
			onTaskCancel(){
				this.operate('cancel')
			},
		}
	}
</script>

<style>
</style>